<?php
$url = $mosConfig_live_site."/administrator/components/com_content/uploads/"; 
$sql = "SELECT id,title FROM #__categories WHERE published=1 AND section=1 ORDER BY ordering ASC, id DESC";
$database->setQuery($sql);
$lsCategory = $database->loadObjectList();
?>
<div style="clear:both; margin-left:5px;"> 
	<div id="title-cat"><div>Sản phẩm mới</div></div>
    <div id="content-cat">
    	<div style="padding:5px; padding-left:0px; padding-right:0px; margin-left:0px; margin-right:5px;">
    	<?php
    	for ($i=0; $i<count($lsCategory); $i++){
    		$linkCat = sefRelToAbs("index.php?option=com_content&task=blogcategory&id=".$lsCategory[$i]->id);
    		$sql = "SELECT id,title,img,img2 FROM #__content WHERE state=1 AND catid=".$lsCategory[$i]->id." ORDER BY ordering ASC, id DESC LIMIT 0,3";
    		$database->setQuery($sql);
    		$lsContent = $database->loadObjectList();
    		?>
    		<div class="clear" style="height:10px;"></div>
    		<div id="title-cat-home"><div id="titletext">&nbsp;&nbsp;<a href="<?php echo $linkCat;?>"><?php echo $lsCategory[$i]->title;?></a></div></div>
            <div>
            	<?php 
            	for ($j=0; $j<count($lsContent); $j++){
            	$link = sefRelToAbs("index.php?option=com_content&task=view&id=".$lsContent[$j]->id);	
            	?>
                      <div id="product_cell1">
                        <a href="<?php echo $link;?>">
                        <?php
						if ($lsContent[$j]->img!=''){
						?>
						<a href="<?php echo $link;?>"><img src="<?php echo $url.$lsContent[$j]->img;?>" /></a>
						<?php
						}else{
						?>
						<a href="<?php echo $link;?>"><img src="<?php echo $url;?>no_pic.gif" /></a>
						<?php
						}
						?>
                        </a>
                        <div id="productname" class="vtip" title="<?php echo $lsContent[$j]->title;?>">
                        	<a href="<?php echo $link;?>"><?php echo $lsContent[$j]->title;?></a>
                        </div>
                      </div>
                <?php }?>       
            </div>
            <div class="clear" style="padding:5px;"></div>
    		<?php
    	} 
    	?>
    	</div>
	</div>
</div>